package com.hqyj.cl.mapper;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hqyj.cl.pojo.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

/**
 * @description：
 * @author：cc
 * @date：2021/10/12 10:23
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:config/spring-mybatis.xml"})
public class TestSQL {
    @Autowired
    private UserMapper userMapper;

    @Test
    public void queryAll(){
        // 使用PageHelper插件分页
        // 开启分页
        PageHelper.startPage(1,1);
        // 查询数据库，获取查询数据
        List<User> users = userMapper.queryAll();
        // 将查询数据封装到PageInfo对象中
        PageInfo<User> userPageInfo = new PageInfo<>(users);
        // 输出PageInfo
        System.out.println(userPageInfo);
    }

}
